﻿using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using EAF.Utility;

namespace App.Admin
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Program start current root path: " + DoPath.ContentRootPath);
#if DEBUG
            "Application environment: Debug program efficiency may be affected!".WriteWarningLine();
#endif
#if RELEASE
            Console.WriteLine("Application environment: Release");
#endif
            //配置文件日志
            EAF.Utility.FileLog.Config.InitializeFileLogConfig("log4net.config");

            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>()
                .ConfigureAppConfiguration((context, builder) =>
                {
                    builder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false);

                    ////Console.WriteLine("环境名:" + context.HostingEnvironment.EnvironmentName);
                    //switch (context.HostingEnvironment.EnvironmentName)
                    //{
                    //    case "Development":
                    //        //vs开发环境读 appsettings.Development.json
                    //        builder.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: false, reloadOnChange: true);
                    //        break;
                    //    default:
                    //        //线上环境使用服务器的配置
                    //        //builder.AddKubernetesConfigmap("aam-machine-api-config", KubeClientOptions.FromPodServiceAccount(), reloadOnChange: true);
                    //        break;
                    //}

                });
            });
    }
}
